import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:rabbit_mobile/i18n/strings.g.dart';
import 'package:rabbit_mobile/provide/riverpod_notifier.dart';
import 'package:rabbit_mobile/view/Category/models/category_model.dart';
import 'package:rabbit_mobile/view/Login/models/login_model.dart';
import 'package:rabbit_mobile/view/goods_details/models/goods_details_model.dart';

import '../view/Home/models/home_model.dart';
import '../view/Mine/models/user_profile_model.dart';
import '../view/Oder_payment/models/payments_model.dart';
import '../view/ShoppingCart/models/shopping_cart_model.dart';

final categoryProvider = StateNotifierProvider<CategoryNotifier, AsyncValue<CategoryFirstLevel>>((ref) {
  final notifier = CategoryNotifier();
  notifier.fetchCategories();
  return notifier;
});

final categorySecondsProvide =
    StateNotifierProvider.family<CategorySecondsLevelNotifier, AsyncValue<CategorySecondsLevel>, String>((ref, id) {
  final notifier = CategorySecondsLevelNotifier();
  notifier.fetchCategoriesSecondsLevel(id);
  return notifier;
});

final loginProvide = StateNotifierProvider.family<LoginNotofier, AsyncValue<LoginModel>, dynamic>((ref, data) {
  final notifier = LoginNotofier();
  notifier.fetchLogin(data);
  return notifier;
});

final goodsDetailsProvide =
    StateNotifierProvider.family<GoodsDetailsNotifier, AsyncValue<GoodsDetailsModel>, String>((ref, id) {
  final notifier = GoodsDetailsNotifier();
  notifier.fetchGoodsDetails(id);
  return notifier;
});

final translationProvider = StateNotifierProvider<LocaleNotifier, AppLocale>(
  (ref) => LocaleNotifier(),
);

final goodsDetailsSpecsProvider =
    StateNotifierProvider<GoodsDetailsSpecsNotifier, List<GoodsDetailsSpecs2Model>>((ref) {
  return GoodsDetailsSpecsNotifier([]);
});

final shoppingCartIsSelectProvide =
    StateNotifierProvider<ShoppingCartIsSelectedNotifier, List<ShoppingCartValidsModel>>((ref) {
  final initialCartData = <ShoppingCartValidsModel>[];
  return ShoppingCartIsSelectedNotifier(initialCartData);
});

final changeShoppingCartStateProvide =
    StateNotifierProvider.family<ChangeShoppingCartStateNotifier, AsyncValue, dynamic>((ref, data) {
  final notifier = ChangeShoppingCartStateNotifier();
  notifier.fetchChangeShoppingCart(data);
  return notifier;
});

final getShoppingProvider = StateNotifierProvider<GetShoppingCartNotifier, AsyncValue<ShoppingCartModel>>((ref) {
  final notifier = GetShoppingCartNotifier();
  notifier.fetchGetShoppingCart();
  return notifier;
});

final getShoppingCartCountProvider =
    StateNotifierProvider<GetShoppingCartCountNotifier, AsyncValue<GetShoppingCartCountModel>>((ref) {
  final notifier = GetShoppingCartCountNotifier(ref);
  notifier.fetchGetShoppingCartCount();
  return notifier;
});

final shoppingCartGoodsTotalCount = StateProvider<int>((ref) => 0);

final guessYouLikeProvider = StateNotifierProvider<GetGuessYouLikeNotifier, AsyncValue<GetGuessYouLikeModel>>((ref) {
  final notifier = GetGuessYouLikeNotifier();
  notifier.fetchGetGuessYouLike();
  return notifier;
});

final userProfileProvide =
    StateNotifierProvider<GetUserProfileInformationNotifier, AsyncValue<UserProfileInformationModel>>((ref) {
  final notifier = GetUserProfileInformationNotifier();
  notifier.fetchUserProfileInformation();
  return notifier;
});

final paymentsGoodsProvider = StateNotifierProvider<PaymentsGoodsNotifier, AsyncValue<PaymentsModel>>((ref) {
  final notifier = PaymentsGoodsNotifier();
  notifier.fetchPaymentsGoods();
  return notifier;
});

final themeModeProvider = StateProvider<ThemeMode>((ref) => ThemeMode.light);
